package com.lanelu.hencoderplusstudy.view.practice;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

import com.lanelu.hencoderplusstudy.view.Utils;

/**
 * 画圆
 */
public class Practice2DrawCircleView extends View {


    private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

    public Practice2DrawCircleView(Context context) {
        super(context);
    }

    public Practice2DrawCircleView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Practice2DrawCircleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        paint.setColor(Color.BLACK);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawCircle(Utils.dp2px(100f), Utils.dp2px(100f), Utils.dp2px(80f), paint);
        paint.setStyle(Paint.Style.STROKE);
        canvas.drawCircle(Utils.dp2px(300f), Utils.dp2px(100f), Utils.dp2px(80f), paint);
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(Color.BLUE);
        canvas.drawCircle(Utils.dp2px(100f), Utils.dp2px(300f), Utils.dp2px(80f), paint);
        paint.setColor(Color.BLACK);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(20);
        canvas.drawCircle(Utils.dp2px(300f), Utils.dp2px(300f), Utils.dp2px(80f), paint);

//        练习内容：使用 canvas.drawCircle() 方法画圆
//        一共四个圆：1.实心圆 2.空心圆 3.蓝色实心圆 4.线宽为 20 的空心圆
    }
}
